/*
 * Copyright 2007 Yegor Jbanov
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.spicesoft.clientobjects.core.collections;

import java.beans.PropertyChangeEvent;

/**
 * A property change event suitable for observable lists of objects. The
 * difference between this class and java.beans.IndexedPropertyChangeEvent
 * is that it accounts for changes in the size of the collection. It also
 * introduces multiple types of supported operations {@link EventType}.
 * 
 * @author Yegor Jbanov
 */
public class VariableLengthIndexedPropertyChangeEvent extends PropertyChangeEvent {

  /**
   * Defines the types of List operations supported by this
   * property change listener.
   */
  public static enum EventType {INSERT, DELETE, MODIFY};
  
  private int startIndex;

  private int endIndex;

  private EventType eventType;

  public VariableLengthIndexedPropertyChangeEvent(Object source, String propertyName,
      Object oldValue, Object newValue, int startIndex, int endIndex, EventType eventType) {
    super(source, propertyName, oldValue, newValue);
    this.startIndex = startIndex;
    this.endIndex = endIndex;
    this.eventType = eventType;
  }

  public int getStartIndex() {
    return startIndex;
  }

  public int getEndIndex() {
    return endIndex;
  }
  
  public EventType getEventType() {
    return eventType;
  }

}
